package com.atguigu.crowd.mvc.controller;

import com.atguigu.crowd.service.AdminService;
import com.atguigu.crowd.util.ResultEntity;
import com.atguigu.entity.Admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class TestController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/test/ssm.html")
    public ModelAndView testSsm(ModelAndView modelAndView){
        Logger logger = LoggerFactory.getLogger(TestController.class);
        List<Admin> adminList = adminService.getAll();
        modelAndView.addObject("adminList",adminList);
        modelAndView.setViewName("target");
        logger.info(String.valueOf(adminList));


        System.out.println(1/0);
        return modelAndView;
    }

    @RequestMapping("/send/array")
    @ResponseBody
    public ResultEntity<List<Integer>> testArray(@RequestBody List<Integer> array){
        for (Integer number:
             array) {
            System.out.println("number:"+number);
        }
        String a = null;
        System.out.println(a.length());
        return ResultEntity.successResuleData(array);
    }
}
